package com.gexiaobao.pigeon.ui.adapter

import android.graphics.Paint
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.PassResultBody
import com.gexiaobao.pigeon.app.util.Util
import com.gexiaobao.pigeon.databinding.ItemLivePerformanceBinding

/**
 * @Author      : hxw
 * @Date        : 2024/7/23 11:40
 * @Describe    :
 */
class AdapterLivePerformance(data: ArrayList<PassResultBody>) :
    BaseQuickAdapter<PassResultBody, DataBindBaseViewHolder>(R.layout.item_live_performance, data) {
    override fun convert(holder: DataBindBaseViewHolder, item: PassResultBody) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemLivePerformanceBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        holder.setVisible(R.id.ivItemLiveVideo, item.operation.videoStatus == 2)

        val ringId = Util.check2FormatRingId(item.ringId)
        holder.setText(R.id.tvItemRingId, ringId)

        val tvItemLiveUserName = holder.getView<AppCompatTextView>(R.id.tvItemLiveUserName)
        tvItemLiveUserName.paint.flags = Paint.UNDERLINE_TEXT_FLAG//设置下划线

        val tvSpeed = holder.getView<AppCompatTextView>(R.id.tvSpeed)
        tvSpeed.paint.flags = Paint.UNDERLINE_TEXT_FLAG//设置下划线

        if (holder.layoutPosition % 2 == 0) {//偶数
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.white))
        } else {
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.comm_bg))
        }
    }
}